# ------------------------------------------
# 准备工作
# ------------------------------------------

setwd("/Users/eimei/Documents/Rdata/")  # 设定工作空间
data <- read.csv("HRdata.csv")  # 读取数据

newdata <- data[c("EmployeeNumber", "Age", "Department",
                  "EnvironmentSatisfaction", "JobSatisfaction",
                  "MonthlyIncome", "RelationshipSatisfaction")]

head(newdata)

# ------------------------------------------
# 任务一
# ------------------------------------------

names(newdata)

names(newdata)[3]

names(newdata)[1] <- "EmployeeID"
names(newdata)[6] <- "MonthlyRate"

names(newdata)

head(newdata)

# ------------------------------------------
# 任务二
# ------------------------------------------

install.packages("reshape")
library(reshape)
newdata <- rename(newdata, c(EnvironmentSatisfaction = "EnvironmentSF",
                  JobSatisfaction = "JobSF",
                  RelationshipSatisfaction = "RelationshipSF"))

head(newdata)
